package com.mew.lobby.handler.gold;

import com.mew.common.exception.ResponseCode;
import com.mew.common.rest.IntMessage;
import com.mew.common.rest.bo.MewSession;
import com.mew.lobby.annotation.LobbyHandler;
import com.mew.lobby.net.LobbyHandlerMapCmdType;
import com.mew.lobby.net.MewHandler;
import com.mew.lobby.provide.GoldFeignService;
import com.zebra.remoting.protocol.ZebraCommand;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author dylin
 * @create 2021/5/24
 */
@Service
@Slf4j
@LobbyHandler(LobbyHandlerMapCmdType.TranRecord)
public class TranRecordHandler implements MewHandler<IntMessage> {
    @Autowired
    private GoldFeignService goldFeignService;

    @Override
    public void handle(ZebraCommand<IntMessage> zebraCommand, MewSession session) {
        Integer type=zebraCommand.getRequest().getI();
        if(type==null){
            zebraCommand.sendFailureCode(ResponseCode.ParamInvalid.code());
            return;
        }
        zebraCommand.sendMessage(goldFeignService.tranRecord(zebraCommand.getUserId(),type));
    }
}
